package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class Login {
    @Value("${server.port}")
    private Integer port;

    @RequestMapping("/set")
    public String set(HttpSession session) {
        session.setAttribute("user", "springboot session");
        return String.valueOf(port);
    }


    @RequestMapping("/get")
    public Object login(HttpSession session) {
        Object attribute = session.getAttribute("user");
        return attribute + " " + port;
    }
}
